package cn.edu.nju.askme.model;
// default package

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;


/**
 * Question entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="question"
    ,catalog="askme"
)

public class Question  implements java.io.Serializable {


    // Fields    

     private Integer id;
     private Paper paper;
     private String title;
     private List<Answer> answers = new ArrayList<Answer>(0);
     private List<Option> options = new ArrayList<Option>(0);


    // Constructors

    /** default constructor */
    public Question() {
    }

	/** minimal constructor */
    public Question(Paper paper, String title) {
        this.paper = paper;
        this.title = title;
    }
    
    /** full constructor */
    public Question(Paper paper, String title, List<Answer> answers, List<Option> options) {
        this.paper = paper;
        this.title = title;
        this.answers = answers;
        this.options = options;
    }

   
    // Property accessors
    @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="id", unique=true, nullable=false)

    public Integer getId() {
        return this.id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
	@ManyToOne(fetch=FetchType.EAGER)
        @JoinColumn(name="pid", nullable=false)

    public Paper getPaper() {
        return this.paper;
    }
    
    public void setPaper(Paper paper) {
        this.paper = paper;
    }
    
    @Column(name="title", nullable=false, length=45)

    public String getTitle() {
        return this.title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    @Transient
    public List<Answer> getAnswers() {
        return this.answers;
    }
    
    public void setAnswers(List<Answer> answers) {
        this.answers = answers;
    }
    @Transient
    public List<Option> getOptions() {
        return this.options;
    }
    
    public void setOptions(List<Option> options) {
        this.options = options;
    }
   








}